<?php
require_once( 'DatasourceDecorator.php' );

class XmlFileDatasource extends DatasourceDecorator {

	var $iLastDdl;

	function XmlFileDatasource( $sXmlFilename ) {

		if ( !file_exists( $sXmlFilename ) ) {
			$this->oDatasource = new NullDatasource();
			$this->oDatasource->AddError( constant( 'ErrorNumber.DatasourceRetrieval' ), 'Xml source file ' . $sXmlFilename . ' does not exist' );
			return;
		}

		$this->iLastDdl = filemtime( $sXmlFilename );

		$oHandle = @fopen( $sXmlFilename, 'r' );
		if ( !is_resource( $oHandle ) ) {
			$this->oDatasource = new NullDatasource();
			$this->oDatasource->AddError( constant( 'ErrorNumber.DatasourceRetrieval' ), 'Could not open Xml source file ' . $sXmlFilename );
			return;
		}
			
		$this->oDatasource = new XmlStreamDatasource( $oHandle );
	}
	
	function GetLastDdl() {
		return $this->iLastDdl;
	}	
}
require_once( 'XmlStreamDatasource.php' );
require_once( 'NullDatasource.php' );

?>
